﻿/**
 * File:   aidl_2_json_converter.c
 * Author: AWTK Develop Team
 * Brief:  convert aidl to json
 *
 * Copyright (c) 2018 - 2020  Guangzhou ZHIYUAN Electronics Co.,Ltd.
 *
 * This program is ditokenizeributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * License file for more details.
 *
 */

/**
 * History:
 * ================================================================
 * 2020-12-09 zhang zhongji <zhangzhongji@zlg.cn> created
 *
 */
#pragma once
#include "aidl_2_json_converter.h"
#include "aidl_parser.h"
#include "json_builder.h"

char* aidl_2_json_converter_convert(const char* aidl_file) {
    return_value_if_fail(aidl_file != NULL, NULL);
    char* result = NULL;

    builder_t* json_builder = json_builder_create();
    if (aidl_parser_convert(aidl_file, strlen(aidl_file), json_builder) == RET_OK) {
        result = json_builder_get_result(json_builder);
    }
    
    json_builder_destroy(json_builder);
    return result;
}